/**
 * 
 */
package exactDiagonalisation;

import static common.Print.println;
import static common.Range.range;

import java.io.File;
import java.io.IOException;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * @author vladimir
 * 
 */
public class ExactDiagonalisation {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		println();
		int N = 3;
		double J = 1;
		double B = 1;

		// int[][] neighbors = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }, { -1,
		// -1 }, { 1, 1 } };

		int[][] neighbors = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
		Hamiltonian H = new Hamiltonian(N, J, B, neighbors);
		// double[] E = new double[40];
		// double[] T = new double[40];

		System.out.println();

		// Create a simple XY chart
		XYSeries series = new XYSeries("XYGraph");
		for (int t = 0; t < 99; t++) {
			double tT = range(0.1, 10.0, 0.1)[t];
			series.add(tT, H.Entropy(tT));
		}
		// Add the series to your data set
		XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(series);
		// Generate the graph
		JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title
				"Temperature", // x-axis Label
				"Energy", // y-axis Label
				dataset, // Dataset
				PlotOrientation.VERTICAL, // Plot Orientation
				true, // Show Legend
				true, // Use tooltips
				false // Configure chart to generate URLs?
				);
		try {
			ChartUtilities.saveChartAsJPEG(new File("chart.jpg"), chart, 1400,
					900);
		} catch (IOException e) {
			System.err.println("Problem occurred creating chart.");
		}
	}
}